package com.hyperplan.neptune.parser.generic;

import java.util.List;

import com.hyperplan.neptune.lexer.Token;

public class ConverterParser<T> implements Parser<T> {

	private Parser<? extends T> parser;
	
	public ConverterParser(Parser<? extends T> parser) {
		this.parser = parser;
	}
	
	public ParserSolution<T> parse(List<Token> tokens, int index) throws ParserException {
		ParserSolution<? extends T> solution = parser.parse(tokens, index);
		return new ParserSolution<T>(solution.getElement(), solution.getIndex());
	}
}
